<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<div class="container-fluid am-margin-top">
    <form id="optBtnForm">
        <input type="hidden" name="id"/>
        <input type="hidden" name="funcPointId"/>
        <div class="form-group">
            <label for="name">前缀</label>
            <input type="text" name="name" class="form-control" placeholder="自动帮你加上'_'">
        </div>
        <div class="form-group">
            <a href="javascript:void(0)" id="optBtnSaveBt"  class="btn btn-primary pull-right">保存</a>
        </div>
    </form>
</div>
<script type="text/javascript">

    $(function () {
        var id = '${param.id}';
        var funcPointId = '${param.funcPointId}';
        $("#optBtnForm").find("input[name=funcPointId]").val(funcPointId);
        var realName = [
            {code: "_ADD",btnCls:"btn-success",btnType:"DEFAULT",icon:"glyphicon glyphicon-plus", name: "添加",notDisplayTitle:"0"},
            {code: "_VIEW",btnCls:"btn-default",btnType:"IN_GRID_ROW",icon:"glyphicon glyphicon-search", name: "查看",notDisplayTitle:"1"},
            {code: "_MOD",btnCls:"btn-primary",btnType:"IN_GRID_ROW",icon:"glyphicon glyphicon-edit", name: "修改",notDisplayTitle:"1"},
            {code: "_DEL",btnCls:"btn-danger",btnType:"IN_GRID_ROW",icon:"glyphicon glyphicon-trash", name: "删除",notDisplayTitle:"1"}
            
        ];

        //事件
        $("#optBtnSaveBt").click(function () {
            var name = $("#optBtnForm").find("input[name=name]").val();
            if (!name) {
                webUtils.alert("请输入前缀");
            } else {
                $.each(realName, function (i, n) {
                    var code = name + n.code;
                    $.ajax({
                        url: ctx + "/optBtnAction/save.do",
                        async: false,
                        data: {funcPointId: funcPointId,btnCls:n.btnCls,btnType:n.btnType,title: n.name, optAuthCode: code,iconCls: n.icon,notDisplayTitle:n.notDisplayTitle},
                        success: function (data) {
                            if (data.success) {
                            } else {
                                webUtils.error(data.msg);
                            }
                        },
                        dataType: "json"
                    });

                });
                top.webUtils.topicPublish("optBtn.edit.success", null);
            }
        });
    });
</script>